//
//  AXHomeZjzdZdzVC.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/11/6.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHomeZjzdZdzVC.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "Header.h"
#import "UITableView+SDAutoTableViewCellHeight.h"
#import "AXHomeZjzdZdzFirstCell.h"
#import "AXHomeZjzdZdzSecondCell.h"
#import "AXHomeZjzdZdzFirstModel.h"
#import "AXHomeZjzdZdzSecondModel.h"

@interface AXHomeZjzdZdzVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic ,strong) UITableView *tableView;


@end

@implementation AXHomeZjzdZdzVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self creatView];
    [self setlayout];
    [self setupNavigationItems];
    self.view.backgroundColor = [UIColor whiteColor];
    
    
}


- (void)creatView {
    /** 表头创建 */
    self.tableView = [[UITableView alloc]init];
    self.tableView.backgroundColor = [UIColor whiteColor];
    /** 去掉cell线 */
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerClass:[AXHomeZjzdZdzFirstCell class] forCellReuseIdentifier:[AXHomeZjzdZdzFirstCell reuseID]];
    [self.tableView registerClass:[AXHomeZjzdZdzSecondCell class] forCellReuseIdentifier:[AXHomeZjzdZdzSecondCell reuseID]];
    [self.view addSubview:self.tableView];
    
}



- (void)setlayout {
    
    
    self.tableView.sd_layout
    .leftSpaceToView(self.view, 0)
    .topSpaceToView(self.view, 0)
    .widthIs(Wi)
    .heightIs(Hi-Hn-44);
    
    
}

- (void)setupNavigationItems {
    
    /** 导航条左边的按钮 */
    //返回按钮
    UIButton *kfBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [kfBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    kfBtn.frame = CGRectMake(0, 0, 30, 30);
    [kfBtn addTarget:self action:@selector(backAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:kfBtn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    
    
}

#pragma mark - Action

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)search:(UIButton *)btn {
    
}



#pragma mark - tableViewDelegate & tableViewDatasorce



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
  
    
    
}


//几个分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
        
        return 3;
    }
    
    return 2;
}

/** cell的高度 */

/** cell 自适应第二步 */
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    return 110;
    
    
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        
        
        AXHomeZjzdZdzFirstCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXHomeZjzdZdzFirstCell reuseID] forIndexPath:indexPath];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
        
        
        
        return cell;
    }
    
    AXHomeZjzdZdzSecondCell *cell = [tableView dequeueReusableCellWithIdentifier:[AXHomeZjzdZdzSecondCell reuseID] forIndexPath:indexPath];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    
    return cell;
    
    
}





@end


